<template>
  <van-card v-for="item in teamlist" :key="item.id" :price="item.product.team" :thumb="item.product.thumbs_text">
    <template #title>
        <h3>{{ item.product.name }}</h3>
    </template>
    <template #desc>
        <div> 人数：<span style="color: red;">{{ item.total }}</span> 人</div>
        <div> 拼团时间：{{ item.createtime_text }} (开始) ~ {{ item.endtime_text }} (结束)</div>
    </template>
    <template #footer>
        <van-button type="danger" size="small" @click="toPages(item)">参与拼团</van-button>
        <van-button type="warning" size="small" @click="toInfoPage(item.id)">拼团详情</van-button>
    </template>
</van-card>
<Footer />
</template>

<script setup>
import Footer from '@/components/common/footer.vue'
const { proxy } = getCurrentInstance()
const teamlist = ref([])

onBeforeMount(()=>{
  getTeamData()
})
const getTeamData = async ()=>{
  let result=await Api.TeamIndex()
  if (result.code == 1) {
    teamlist.value=result.data
  }
}

// 参与拼团
const toPages=(val)=>{
  proxy.$router.push({
    path: '/product/detail',
    query: {
      pid: val.proid
    }
  })
}

// 拼团详情
const toInfoPage=(id)=>{
  proxy.$router.push({
    path: '/team/info',
    query: {
      teamid: id
    }
  })
}
</script>

<style>
.van-card__content{
  text-align: left;
}
</style>